package com.lwl.controller.sas;


import com.github.pagehelper.PageInfo;
import com.lwl.entity.*;
import com.lwl.entity.sas.SasTongji1;
import com.lwl.entity.sas.SasTongji2;
import com.lwl.entity.sas.TSasRecord;
import com.lwl.service.sas.TSasRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("tSasRecord")
public class TSasRecordController {
    @Autowired
    private TSasRecordService tSasRecordService;

    @GetMapping("queryAll")
    public LayData queryAll(MyPage myPage, TSasRecord tSasRecord){
        PageInfo pageInfo = tSasRecordService.queryAll(myPage,tSasRecord);
        return new LayData(pageInfo);
    }

    /**
     * 添加做题记录到数据库
     */
    @PostMapping("addRecord")
    public LayData addRecord(TSasRecord tSasRecord){
        int insert = tSasRecordService.insertRecord1(tSasRecord);
        return new LayData(insert);
    }


    @GetMapping("statistics2")
    public LayData getStatistics2(MyPage myPage, SasTongji2 sasTongji2){
        PageInfo pageInfo = tSasRecordService.getStatistics2(myPage,sasTongji2);
        return new LayData(pageInfo);
    }
//
    @GetMapping("statistics1")
    public LayData getStatistics1(){
        List<SasTongji1> sasTongji1List = tSasRecordService.getStatistics1();
        return new LayData(sasTongji1List);
    }
    /**
     * 电话号的唯一性检验
     * @param tSasRecord
     * @return
     */
    @GetMapping("checkRecord")
    public LayData checkRecord(TSasRecord tSasRecord){
        TSasRecord tSasRecords = tSasRecordService.checkRecord(tSasRecord);
        return new LayData(tSasRecords);
    }

    /**
     * 查询做题详情
     * @return
     */
    @GetMapping("recordDetails/{id}")
    public LayData recordDetails(@PathVariable Integer id,MyPage myPage){
        PageInfo pageInfo = tSasRecordService.recordDetails(id,myPage);
        return new LayData(pageInfo);
    }

}

